Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@commitlint/lint
Advanced tools
The @commitlint/lint package is a part of the commitlint toolset that is used to lint commit messages according to a specified set of rules. It helps maintain a consistent commit history and enforces a commit message convention, which is beneficial for automated processing of commit logs, generating changelogs, and aiding in code reviews.
Linting Commit Messages
This feature allows you to lint commit messages using a set of predefined rules. The code sample demonstrates how to use the lint function to check if a commit message follows the specified rules for the commit type and subject case.
const { lint } = require('@commitlint/lint');
const message = 'feat: add new feature';
const rules = {
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore']],
'subject-case': [2, 'never', ['start-case', 'pascal-case', 'upper-case']]
};
lint(message, rules).then(report => {
console.log(report);
});
commitlint is the core package that includes @commitlint/lint as part of its toolset. It provides a CLI and can be extended with plugins and shareable configurations. It is essentially the same tool but with a broader scope.
conventional-changelog-lint is a predecessor to commitlint and offers similar functionality for linting commit messages based on the conventional changelog standard. It has been deprecated in favor of commitlint.
validate-commit-msg is another deprecated package that was used to validate commit messages. It has been replaced by commitlint, which offers a more modern and flexible approach to commit message validation.
Lint a string against commitlint rules
npm install --save @commitlint/lint
const lint = require('@commitlint/lint').default;
lint('foo: bar', {'type-enum': [1, 'always', ['foo']]}).then((report) =>
console.log(report)
);
// => { valid: true, errors: [], warnings: [] }
lint('foo: bar', {'type-enum': [1, 'always', ['bar']]}).then((report) =>
console.log(report)
);
/* =>
{ valid: true,
errors: [],
warnings:
[ { level: 1,
valid: false,
name: 'type-enum',
message: 'type must be one of [bar]' } ] }
*/
Consult docs/api for comprehensive documentation.
FAQs
Lint a string against commitlint rules
The npm package @commitlint/lint receives a total of 1,973,708 weekly downloads. As such, @commitlint/lint popularity was classified as popular.
We found that @commitlint/lint demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.